//商品上架
$(function(){
	//搜索
	$('.searchBar').click(function(){
		var thisform=$(this).parent('form');
		var order_no=thisform.find('input[name=order_no]').val();
		var manual_id=thisform.find('input[name=manual_id]').val();
		var goods_no=thisform.find('input[name=goods_no]').val();
		var goods_name=thisform.find('input[name=goods_name]').val();
		var cloud_depot_status=thisform.find('.cloud_depot_status').combobox('getValue');
		var start_time=thisform.find('input[name=start_time]').val();
		var end_time=thisform.find('input[name=end_time]').val();
		var time_cate=6;//过期时间
		// console.log(inbound_status);
		// return false;
		$('#overdueDatagrid').datagrid('options').pageNumber=1;//设置页码初始值为1
		$('#overdueDatagrid').datagrid({ 
			url:getarrivalUrl,
			queryParams:{
				status:1,//已审核通过
				order_no:order_no,
				grounding_status:1,//未上架
				manual_id:manual_id,
				goods_no:goods_no,
				goods_name:goods_name,
				inbound_status:1,//已入库
				cloud_depot_status:cloud_depot_status,
				start_time:start_time,
				end_time:end_time,
				time_cate:time_cate
			}
		});
	})
	
	$('#overdueDatagrid').datagrid({
		//url:getarrivalUrl+"?randnum="+Math.floor(Math.random()*1000000),
		url:getarrivalUrl,
		title:'库存商品明细列表',
		fitColumns:true,
		rownumbers:true,
		pageSize:25,
		pageNumber:1,
		pageList:[5,10,15,20,25,30,40,50],
		queryParams:{
			status:1,
			inbound_status: 1,
			grounding_status:1//未上架
		},
		columns:[[
		{field:'id',title:'id',checkbox:true},
		{field:'order_no',title:'单号',sortable:true},
		{field:'manual_id',title:'账册编号'},
		{field:'goods_no',title:'商品编码'},
		{field:'goods_name',title:'商品名称'},
		{field:'goods_spec',title:'规格'},
		{field:'bar_code',title:'条形码'},
		{field:'storage_code',title:'库位',sortable:true,width:'100px',
			editor:{
				type:'combobox',
				options:{
					valueField:'id',
					textField:'name',
					method:'get',
					url:storageListUrl,
					required:true,
					validType:['selected[]']
				}
			}
		},
		{field:'cloud_depot_status',title:'是否云仓商品',sortable:true},
		{field:'cloud_num',title:'云仓商品数量',sortable:true},
		{field:'cloud_unit',title:'云仓商品单位',sortable:true},
		{field:'conforming_p',title:'合格品',sortable:true},
		{field:'nonconforming_p',title:'残次品',sortable:true},
		{field:'scrap_one',title:'报废品',sortable:true},
		{field:'overdue_time',title:'过期时间',sortable:true},
		{field:'overdue_time_str',title:'过期剩余天数',sortable:true,width:150},
		]],
		onLoadError:function(data){
			var info=eval('('+data.responseText+')');
			$.messager.confirm('错误提示',info.message,function(r){
				var tab=$('#Tabs').tabs('getSelected');
				var index=$('#Tabs').tabs('getTabIndex',tab);
				$('#Tabs').tabs('close',index);
			});
		},
		// rowStyler:function(index,row){
			// if (row.color==0){
				// return 'background-color:pink;color:blue;font-weight:bold;';
			// }
		// },
		pagination:true,
		fit:true,
	});
});
overdueObj={
	overdueBar:function(monthx,monthy,week){
		// alert(monthx);
		$('#overdueDatagrid').datagrid({
			url:overduefastUrl,
			queryParams:{
				status:1,
				inbound_status: 1,
				grounding_status:1,//已上架
				monthx:monthx,
				monthy:monthy,
				week:week
			}
		})
	},
	showAll:function(){
		$('#overdueDatagrid').datagrid({ 
			url:getarrivalUrl,
			queryParams:{status:1,grounding_status:1,inbound_status:1}//已入库参数
		});
	}
}